#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e5 + 5;

int n, m;
map<int, int> mp;
bool boo[N];
int nexti[N];
int ar[N];
priority_queue<int> q;
int num, ans;

void solve() {
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> ar[i];
    for (int i = n; i >= 1; i--) {
        if (mp[ar[i]] == 0)
            nexti[i] = N;
        else
            nexti[i] = mp[ar[i]];
        mp[ar[i]] = i;
    }
    for (int i = 1; i <= n; i++) {
        if (boo[i] == 0) {
            ans++;
            if (num < m) {
                num++;
                boo[nexti[i]] = 1;
                q.push(nexti[i]);
            } else {
                boo[q.top()] = 0;
                q.pop();
                boo[nexti[i]] = 1;
                q.push(nexti[i]);
            }
        } else {
            boo[nexti[i]] = 1;
            q.push(nexti[i]);
        }
    }
    cout << ans << endl;
    return;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}